package com.satan.juc.demo9;

import java.util.concurrent.locks.ReentrantLock;

public class LockDemo {
    private static ReentrantLock lock = new ReentrantLock();
    private static int  count=0;
    public static void main(String[] args) throws InterruptedException {
        for (int i = 0; i < 5; i++) {
            Thread thread = new Thread(() -> {
//                lock.lock();
                lock.tryLock();
                try {
//                    Thread.sleep(10000);
                    count++;
                } finally {
                    lock.unlock();
                }
            });
            thread.start();
        }
        Thread.sleep(1000);
        System.out.println(count);
    }
}